<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <script>
        var a = 5;
        try {
            if (a == 5) {
                //   抛出错误
                throw new Error("a是5的时候就报错"); //Error要大写
            }
        } catch (e) {
            console.log(e); //打印出Error对象：Error: loopTerminates
            console.log(e.message); //打印：loopTerminates
        }
    </script>
</body>

</html>